import com.maochang.top.dao.UserDao;
import com.maochang.top.dao.impl.UserDaoImpl;
import com.maochang.top.service.impl.UserServiceImpl;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class annotation {
    /**
     * 测试注解+包扫描
     * 检测Dao层的类是否已经在容器中声明
     */
    @Test
    public  void  annotTest01(){
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("beans.xml");
        //子类可以用父类进行接收
        UserDaoImpl userDaoImpl = applicationContext.getBean("userDaoImpl", UserDaoImpl.class);
        System.out.println(userDaoImpl.save());
    }

    /**
     * 测试注解+包扫描
     * 检测业务层的类是否已经在容器中声明
     */
    @Test
    public  void  annotTest02(){
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("beans.xml");
        UserServiceImpl userDaoImpl = applicationContext.getBean("userServiceImpl", UserServiceImpl.class);
        System.out.println(userDaoImpl.add());
    }
}
